<?php

	//get specials
	$SQL = "SELECT * FROM products WHERE is_onSpecial =1";
	$result = mysql_query($SQL, $db);
	
	$ctr = 0;
	//fill the product array
	while($data = mysql_fetch_array($result)) {
		//fill the product array with this products information
		if($data["isActive"] == 1)
		{
		$prodArray[$ctr]["id"] = $data["id"];
		$prodArray[$ctr]["name_en"] = $data["name_en"];
		$prodArray[$ctr]["name_fr"] = $data["name_fr"];
		$prodArray[$ctr]["desc_en"] = $data["desc_en"];
		$prodArray[$ctr]["desc_fr"] = $data["desc_fr"];
		$prodArray[$ctr]["thumb_URL"] = $data["thumb_URL"];
		$ctr++;
		}
	}
	?>
	<table width="160" border="0" cellspacing="0" cellpadding="0" style="background-color:#fdfdfd;">
	<tr><td colspan="3">
	<?php if($lg == "US")
		{
			echo "<img src=\"images/nouveaute_en.gif\" width=\"159\" />";
		}
		else
		{
			echo "<img src=\"images/nouveaute.gif\" width=\"159\" />";
		}
	?></td></tr>
<tr><td style="background-image:url(images/special_divider.gif); background-repeat:repeat-y;"><div style="width:1px; margin-left:0px;">&nbsp;</div></td>
<td>
<div style="margin-top:26px; margin-right:-15px;">
<table width="160" border="0" cellspacing="0" cellpadding="0">
  <?php //print the products
	$rowCount = 0;
	$colCount = 0;
  	for($i=0; $i < 1; $i++)
	{
		$value = $prodArray[$i]["id"];
		$name_en = $prodArray[$i]["name_en"];
		$name_fr = $prodArray[$i]["name_fr"];
		$desc_en = $prodArray[$i]["desc_en"];
		$desc_fr = $prodArray[$i]["desc_fr"];
		if($prodArray[$i]["thumb_URL"] == NULL)
		{
			$img = "admin/catalogueImages/locamedic.jpg";
		}
		else
		{
			$img = "admin/catalogueImages/" . $prodArray[$i]["thumb_URL"];
		}
		
		if($colCount < 1)
		{
			if($rowCount == 0)
			{
				echo "<tr>";
				printProduct2($value, $name_en, $name_fr, $desc_en, $desc_fr, $img, $a, $lg);
				$rowCount++;
				$colCount++;
			}
			else
			{
				printProduct2($value, $name_en, $name_fr, $desc_en, $desc_fr, $img, $a, $lg);
				$colCount++;
			}
		}
		else
		{
			if($rowCount < 1)
			{
				//print a new tr and data
				$colCount = 0;
				echo "</tr><tr>";
				printProduct2($value, $name_en, $name_fr, $desc_en, $desc_fr, $img, $a, $lg);
				$colCount++;
				$rowCount++;
			}
			else
			{
				//end this page is products
				echo "</tr>";
				//save where we left off
				//$nextProd = $i;
				//break out of the loop
				$i = 1;
			}
		}
	}
	
  ?>
</table></div>
</td><td style="background-image:url(images/special_divider_right.gif); background-repeat:repeat-y;"><div style="width:1px; margin-left:0px;">&nbsp;</div></td></tr>
<tr><td colspan="3" height="1"><div align="left" style="margin-left:2px; margin-top:-1px;"><img src="images/special_hor_divider.gif" width="156" /></div></td></tr>
</table>
<?php
	function printProduct2($value, $name_en, $name_fr, $desc_en, $desc_fr, $img, $a, $lg)
	{
		if($lg == "US")
		{
			$name = $name_en;
			$desc = $desc_en;
		}
		else
		{
			$name = $name_fr;
			$desc = $desc_fr;
		}
		
		//$list = $_SESSION["printList"];
		//$added = false;
		/*for($i=0; $i < count($list); $i++)
		{
			if($list[$i] == $value)
			{
				$added = true;
			}
		}*/
		//if($added == false)
		//{
			echo "<td width=\"135\" valign=\"top\"><div align=\"center\"><div><table width=\"125\"><tr><td valign=\"middle\" height=\"125\"><a style=\"text-decoration:none;\" href=\"?a=2&lg=$lg&productDetails=1&id=$value\"><img style=\"max-height:125px; max-width:125px; border-style:solid; border-width:2px; border-color:#D4DFFF;\" src=\"$img\" border=\"0\" /></a></td></tr></table></div><a class=\"texthd2rd\" style=\"margin-top:5px; font-family:Verdana, Helvetica, sans-serif; font-weight:normal; font-size:12px;\" href=\"?a=2&lg=$lg&productDetails=1&id=$value\">$name</a><br /><span style=\"margin-top:5px; font-family:Arial, Helvetica, sans-serif; font-weight:bold;\">$desc</span></div><br /></td>";
		//}
		//else
		//{
			//echo "<td><div align=\"center\"><div style=\"border-style:solid; border-width:thin; border-color:#D4DFFF;\"><table width=\"150\"><tr><td valign=\"middle\" height=\"150\"><a style=\"text-decoration:none;\" href=\"?inc=productDetails.php&id=$value&lg=$lg&a=$a\"><img style=\"max-height:150px; max-width:150px;\" src=\"$img\" border=\"0\" /></a></td></tr></table></div><span style=\"margin-top:5px; font-family:Arial, Helvetica, sans-serif; font-weight:bold;\">$name</span><br /><a style=\"text-decoration:none; color:#E6992C; font-size:12px; font-family:Arial, Helvetica, sans-serif;\" href=\"?inc=productDetails.php&id=$value&lg=$lg&a=$a\">$details<a/>&nbsp;|&nbsp;<span style=\"text-decoration:none; color:#000000; font-size:12px; font-family:Arial, Helvetica, sans-serif;\">$addedTxt</span></div></td>";
		//}
	}
?>